//<!-- 收费员报表 -->
export default {
  data () {
    return {
      parkNameListRow: {
        searchParams:{},
        pageNumber:1,
        total: 0,
        theadsInfo: [
          { index: 0, isShow: false, prop: 'reno', text: '序号', width: 68 },
          { index: 1, isShow: false, prop: 'm', text: '停车场', minWidth: 110 }
        ],
        tbodysInfo: []
      },
      parkNameRow:{}
    }
  },
  created () {
    //this.getList();
  },
  methods: {
    // 重新生成按钮
    reBuild(){
      this.$refs.myReBuildBtn.reBuild()
    },
    getDefaultParams(){//获取不能缺少的默认的参数
        let self = this;
        let searchParams = self.searchParams,
            searchList = self.searchList,
            result = {};
            console.log(searchList);
            var itemreportDimension,itemdateFromTo;
            for (var key in searchList) {
                if (searchList.hasOwnProperty(key)) {
                    var item = searchList[key];
                    console.log(item);
                    if(item.name=='reportDimension'){
                        itemreportDimension = item;
                    }else if(item.name=='dateFromTo'){
                        itemdateFromTo = item;
                    }
                }
            }
        return result;
    },
    getList () {
      let params = $.extend({}, this.searchParams, this.otherParams,this.getDefaultParams());
      this.getUseRecordListData(params);
    },
    getUseRecordListData (aparams) {//查询列表
      let self = this,
          params = {
            page: this.pageNumber,
            rp: this.pageSize
          };
      params = $.extend({}, params, aparams);

      API.cityCoupon.GetUseRecordListData(params)
          .then(res => {
            let data = res.data,
                list = data.rows;
            self.tbodysInfo = list;
            self.total = data.total;
          }, err => {})
    },
    exportData(){//导出
      let self = this;
      this.showDialog("是否确认导出记录？",[],function(){
        let params = {
        };
        params = $.extend({}, params, self.searchParams, self.otherParams,self.getDefaultParams());

        console.log(params);
        self.toExportAsync('cityCoupon/useRecord/export.do', params);
      },"温馨提示",function(){
        //取消时不操作
      });
    },
    filterMultiCheck (selectionArr) {//必须定义获取多列的方法
      let result = [];
        selectionArr.map((item)=>{
          result.push(item.id);
        });
      return result;
    },
    handleSearchChange(item) {
      switch(item.name) {
        case 'reportDimension': this.changeReportDimension(item); break;
      }
    },
    changeReportDimension (item) {
      let value = item.value,
          ThisSearchItem = this.searchList[0];
       var today = [new Date(moment().add(-7, 'days').format('YYYY-MM-DD 00:00:00')), new Date(moment().add(1, 'days').format('YYYY-MM-DD 00:00:00'))];
      var month = [new Date(moment().add(-1, 'months').format('YYYY-MM-DD 00:00:00')), new Date(moment().format('YYYY-MM-DD 00:00:00'))];
      var year = [new Date(moment().add(-1, 'years').format('YYYY-MM-DD 00:00:00')), new Date(moment().format('YYYY-MM-DD 00:00:00'))];
      switch (value) {
        case 'day': ThisSearchItem.type = 'datePicker'; ThisSearchItem.pickerType = ''; ThisSearchItem.format = 'yyyy-MM-dd';ThisSearchItem.value = today;break;
        case 'month': ThisSearchItem.type = 'datePicker'; ThisSearchItem.pickerType = 'daterange'; ThisSearchItem.format = 'yyyy-MM';ThisSearchItem.value = month;break;
        case 'year': ThisSearchItem.type = 'datePicker'; ThisSearchItem.pickerType = 'daterange'; ThisSearchItem.format = 'yyyy';ThisSearchItem.value = year;break;
        case 'custom': ThisSearchItem.type = 'datePicker'; ThisSearchItem.pickerType = 'daterange'; ThisSearchItem.format = 'yyyy-MM-dd';ThisSearchItem.value = today;break;
      }
    }
  }
}